package blackhouse.advanced.process;

import java.io.*;

public class TestInOut implements Runnable
{
	Process p = null;

	public TestInOut()
	{
		try
		{
			p = Runtime.getRuntime().exec("java MyTest");
			new Thread(this).start();
		} catch (IOException e)
		{
			e.printStackTrace();
		}
	
	}

	public static void main(String[] args)
	{      
           TestInOut tio= new TestInOut();
	}

	@Override
	public void run()
	{
		InputStream ips = p.getInputStream();
		BufferedReader bfr = new BufferedReader(new InputStreamReader(ips));
		try
		{
			while (true)
			{
				System.out.println(bfr.readLine());
			}
		} catch (IOException e)
		{
			e.printStackTrace();
		}
	}

	public void send()
	{
		try
		{
			OutputStream ops = p.getOutputStream();
			while (true)
			{
				ops.write("help\r\n".getBytes());
			}
		} catch (IOException e)
		{
			e.printStackTrace();
		}

	}
}
